package com.bicon.botu.mall.component.api;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.bicon.botu.mall.component.entity.HotSearch;
import com.bicon.botu.core.base.common.Constants;
import com.bicon.botu.core.base.common.controller.BaseController;
import com.bicon.botu.core.base.common.entity.BaseResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 热搜 前端控制器
 *
 * @author 张露晨
 * @date 2017/7/19 下午 14:49
 */
@RestController
@RequestMapping("/V2.0.0/api/hotSearch")
public class HotSearchApiV2 extends BaseController {


    /**
     * 获取所有热词
     *
     * @param type
     * @return
     */
    @RequestMapping(value = "/getHotSearch", method = RequestMethod.POST)
    public BaseResult getHotSearch(@RequestParam("type") String type) {
        List<HotSearch> hotSearchList = new HotSearch().selectList(new EntityWrapper<HotSearch>()
                .eq("logic_delete", Constants.DEL_LOGIC_NORMAL)
                .eq("type", type).orderBy("sort", false));
        return new BaseResult(Constants.RESPONSE_CODE_200, Constants.RESPONSE_MESSAGE_200, hotSearchList);
    }
}
